home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Mark Pilgrim / Lose Your Marbles! 1.0 / source / ls code ƒ / V bars scroll thin fade.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-30  |  3.5 KB  |  143 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        V bars scroll thin fade.c
  4.  
  5. Purpose:    Graphic effect to fade main window to solid pattern.
  6.             See comments below for more description.
  7.  
  8. This program is free software; you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation; either version 2 of the License, or
  11. (at your option) any later version.
  12.  
  13. This program is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. GNU General Public License for more details.
  17.  
  18. You should have received a copy of the GNU General Public License
  19. along with this program in a file named "GNU General Public License".
  20. If not, write to the Free Software Foundation, 675 Mass Ave,
  21. Cambridge, MA 02139, USA.
  22.  
  23. \**********************************************************************/
  24.  
  25. #include "timing.h"
  26. #include "V bars scroll thin fade.h"
  27.  
  28. #define CorrectTime 3
  29. #define theWindowWidth (boundsRect.right-boundsRect.left)
  30. #define theWindowHeight (boundsRect.bottom-boundsRect.top)
  31.  
  32. pascal short VerticalBarsScrollThinFade(Rect boundsRect, Pattern *thePattern)
  33. {
  34.     RgnHandle        topRgn, bottomRgn;
  35.     short            offset;
  36.     short            iter;
  37.     short            barWidth;
  38.     GrafPtr            curPort;
  39.     RgnHandle        topDestRgn, bottomDestRgn;
  40.     Rect            topDestRect, bottomDestRect;
  41.     Rect            topSourceRect, bottomSourceRect;
  42.     
  43.     offset=5;
  44. //    barWidth=theWindowWidth/40;
  45.     barWidth=1;
  46.     
  47.     topRgn=NewRgn();
  48.     OpenRgn();
  49.         MoveTo(0, 0);
  50.         iter=0;
  51.         while (iter<theWindowWidth)
  52.         {
  53.             Line(0, theWindowHeight);
  54.             Line(barWidth, 0);
  55.             Line(0, -theWindowHeight);
  56.             Line(-barWidth, 0);
  57.             Move(barWidth*2, 0);
  58.             iter+=barWidth*2;
  59.         }
  60.     CloseRgn(topRgn);
  61.     OffsetRgn(topRgn, boundsRect.left, boundsRect.top);
  62.     
  63.     topDestRgn=NewRgn();
  64.     OpenRgn();
  65.         MoveTo(0, 0);
  66.         iter=0;
  67.         while (iter<theWindowWidth)
  68.         {
  69.             Line(0, offset);
  70.             Line(barWidth, 0);
  71.             Line(0, -offset);
  72.             Line(-barWidth, 0);
  73.             Move(barWidth*2, 0);
  74.             iter+=barWidth*2;
  75.         }
  76.     CloseRgn(topDestRgn);
  77.     OffsetRgn(topDestRgn, boundsRect.left, boundsRect.top);
  78.     
  79.     bottomRgn=NewRgn();
  80.     OpenRgn();
  81.         MoveTo(barWidth, theWindowHeight);
  82.         iter=0;
  83.         while (iter<theWindowWidth)
  84.         {
  85.             Line(0, -theWindowHeight);
  86.             Line(barWidth, 0);
  87.             Line(0, theWindowHeight);
  88.             Line(-barWidth, 0);
  89.             Move(barWidth*2, 0);
  90.             iter+=barWidth*2;
  91.         }
  92.     CloseRgn(bottomRgn);
  93.     OffsetRgn(bottomRgn, boundsRect.left, boundsRect.top);
  94.     
  95.     bottomDestRgn=NewRgn();
  96.     OpenRgn();
  97.         MoveTo(barWidth, theWindowHeight);
  98.         iter=0;
  99.         while (iter<theWindowWidth)
  100.         {
  101.             Line(0, -offset);
  102.             Line(barWidth, 0);
  103.             Line(0, offset);
  104.             Line(-barWidth, 0);
  105.             Move(barWidth*2, 0);
  106.             iter+=barWidth*2;
  107.         }
  108.     CloseRgn(bottomDestRgn);
  109.     OffsetRgn(bottomDestRgn, boundsRect.left, boundsRect.top);
  110.     
  111.     topSourceRect=topDestRect=bottomSourceRect=bottomDestRect=boundsRect;
  112.     topSourceRect.bottom-=offset;
  113.     topDestRect.top+=offset;
  114.     bottomSourceRect.top+=offset;
  115.     bottomDestRect.bottom-=offset;
  116.     
  117.     GetPort(&curPort);
  118.     iter=0;
  119.     while (iter<theWindowHeight)
  120.     {
  121.         StartTiming();
  122.         
  123.         CopyBits(&(curPort->portBits), &(curPort->portBits), &topSourceRect,
  124.             &topDestRect, 0, topRgn);
  125.         CopyBits(&(curPort->portBits), &(curPort->portBits), &bottomSourceRect,
  126.             &bottomDestRect, 0, bottomRgn);
  127.         FillRgn(topDestRgn, *thePattern);
  128.         FillRgn(bottomDestRgn, *thePattern);
  129.         
  130.         iter+=offset;
  131.         TimeCorrection(CorrectTime);
  132.     }
  133.     
  134.     FillRect(&boundsRect, *thePattern);
  135.     
  136.     DisposeRgn(topRgn);
  137.     DisposeRgn(bottomRgn);
  138.     DisposeRgn(topDestRgn);
  139.     DisposeRgn(bottomDestRgn);
  140.     
  141.     return 0;
  142. }
  143.